package com.example.myapplication;

public class Fruit {

    private static Fruit fruit;

    private Apple apple;

    private Fruit() {
    }

    public static synchronized Fruit getInstance() {
        if (fruit == null) {
            fruit = new Fruit();
        }
        return fruit;
    }

    public Apple getApple() {
        return apple;
    }

    public Apple getAppleByPrice(int price){
        apple.setPrice(price);
        return apple;
    }

    public void setApple(Apple apple) {
        this.apple = apple;
    }
}
